package com.huluobo.a2204kotlinshopping.adapter

import android.widget.CheckBox
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.huluobo.a2204kotlinshopping.R
import com.huluobo.a2204kotlinshopping.utils.ImageUtils
import com.huluobo.base.bean.CartBean

/**
 *  Created by LC on 2024/7/30.
 */
class CartAdapter(list: MutableList<CartBean>) : BaseQuickAdapter<CartBean, BaseViewHolder>(R.layout.item_cart, list) {
    override fun convert(helper: BaseViewHolder, item: CartBean) {
        ImageUtils.loadImage(context, item.goods_default_icon, helper.getView(R.id.item_cart_icon_iv))
        helper.setText(R.id.item_cart_desc_tv, item.goods_desc)
        helper.setText(R.id.item_cart_price_tv, "价格:￥${item.goods_default_price}元")
        helper.setText(R.id.item_cart_num_tv, item.count.toString())
        //选中按钮的赋值
        helper.getView<CheckBox>(R.id.item_cart_cb).isChecked = item.isChecked
    }
}